package com.leetcode.根据数据结构分类.数组;

/**
 * @author: xiaomi
 * @date: 2021/1/24
 * @description: 674. 最长连续递增序列
 * https://leetcode-cn.com/problems/longest-continuous-increasing-subsequence/
 */
public class A_674_最长连续递增序列 {
    public static void main(String[] args) {
        int[] nums = new int[]{1, 3, 5, 7};
        A_674_最长连续递增序列 action = new A_674_最长连续递增序列();
        int res = action.findLengthOfLCIS(nums);
        System.out.println("res = " + res);
    }

    /**
     * @param nums
     * @return
     */
    public int findLengthOfLCIS(int[] nums) {
        int res = 0;
        int len = nums.length;
        if (len < 2) {
            return len;
        }
        int value = 0;
        int i = 1;
        for (; i < len; i++) {
            if (nums[i] > nums[i - 1]) {
                value++;
            } else {
                res = Math.max(value + 1, res);
                value = 0;
            }
        }
        //边界条件处理！！！
        if (i == len ) {
            res = Math.max(res, value + 1);
        }
        return res;
    }
}
